<?php

/* *
 * 资讯
 */
namespace Common\Model;
use Think\Model;
class GroupOrderModel extends BaseModel {

    public function queryForList($page=null, $map=null) {
        $list = $this->alias("go")
            ->join("left join __ORDER__ o on o.order_id = go.order_id")
            ->join("left join __PRODUCT__ p on p.product_id = o.product_id")
            ->join("left join __CUSTOMER__ cus on cus.customer_id = o.customer_id")
            ->where(getWhereSqlByMap($map))
            ->order(array("go.group_code" => "desc", "o.status" => "asc", "go.create_time" => "desc"))
            ->limit($page->firstRow . ',' . $page->listRows)
            ->field("go.*, p.product_id, p.product_name, p.image_url, cus.nickname, p.group_price, o.price, o.size, o.number, o.status, o.patient_name, o.pay_time, o.need_invoice, o.invoice_name, o.invoice_number, o.receive_name, o.receive_contact, o.receive_address,o.express_company, o.delivery_number, o.outstock_time, o.note")
            ->select();

        return $list;

    }

    public function getListCount($map = null) {

        $count = $this->alias("go")
            ->where(getWhereSqlByMap($map))
            ->count();

        return $count;
    }

}

